package be.tihh.mgmt.gui.util;

import be.tihh.mgmt.tasks.Task;

import javax.swing.*;
import java.awt.*;

public class TaskListIconListCellRenderer
	extends DefaultListCellRenderer {

    @Override
	public Component getListCellRendererComponent(
		JList list, Object value, int index,
		boolean isSelected, boolean cellHasFocus) {

		// Get the renderer component from parent class

        Task task = (Task)value;
        String text = task.getName()+" ---> "+task.getTaskStatus();

		JLabel label =
			(JLabel) super.getListCellRendererComponent(list,
				text, index, isSelected, cellHasFocus);

		// Get icon to use for the list item value

		Icon icon = task.getTaskStatus().getIcon();

		// Set icon to display for value

		label.setIcon(icon);
		return label;
	}

}